import request from "@/utils/request";

/**
 *
 * 查询分页数据
 * @param {*} params
 * @returns
 */
export function queryList(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdServiceMaterial/queryList",
    method: "get",
    params: params
  });
}

/**
 * 保存材料数据
 * @param {*} data
 * @returns
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdServiceMaterial/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据主键oid查询数据
 * @param {*} materialOid
 * @returns
 */
export function queryByMaterialOid(materialOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdServiceMaterial/queryByMaterialOid",
    method: "get",
    params: {
      materialOid
    }
  });
}

/**
 * 根据材料的业务主键删除材料
 * @param {*} materialOid
 * @returns
 */
export function deleteByMaterialOid(materialOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/thirdServiceMaterial/deleteByMaterialOid/${materialOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 通过materialCode 查询是否存在材料，true 存在 false 不存在
 * @param {*} materialCode
 */
export function checkExistByMaterialCode(materialCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdServiceMaterial/checkExistByMaterialCode",
    method: "get",
    params: {
      materialCode
    }
  });
}

/**
 * 下载模板的路径
 * @returns
 */
export function excelExportMaterial() {
  return (
    process.env.VUE_APP_BASE_API +
    process.env.VUE_APP_KSTB_ROUTE_PATH +
    `/yxpz/thirdServiceMaterial/excelExportMaterial`
  );
}

/**
 * 导入excel事项数据
 */
export function importExcel(insertPatter) {
  return (
    process.env.VUE_APP_BASE_API +
    process.env.VUE_APP_KSTB_ROUTE_PATH +
    `/yxpz/thirdServiceMaterial/importExcel/${insertPatter}`
  );
}
